/**
 用于测试promise的模型代码是否能够按照流程顺利返回需要的值
 */

var AV = require('leanengine');

var Version = AV.Object.extend("Version");

var query = new AV.Query(Version);

module.exports = {
    test:function(){
        var q = query.first().then(function(v) {
            var promise = new AV.Promise();
            new AV.Query(AV.Object.extend("_User")).equalTo('username','oA7dTs069QSv7HNdeF-RcntWS_KY').first().then(function(u){
                if(u.get('amount') === 70){
                    promise.resolve('ok');
                }else{
                    promise.reject('err');
                }
            });

            return promise;
        });

        return q;

    },
    test1:function(){
        var q = query.first().then(function(v) {
            var promise = new AV.Promise();
            new AV.Query(AV.Object.extend("_User")).equalTo('username','oA7dTs069QSv7HNdeF-RcntWS_KY').first().then(function(u){
                if(u.get('amount') === 71){
                    promise.resolve('ok');
                }else{
                    promise.reject("err");
                }
            });

            return promise;
        });

        return q;

    },
    test2:function(){
        return new Promise(function(){
        });
    }

};